Socket
Socket
Sign inDemoInstall

redis-parser

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-parser

Javascript Redis protocol (RESP) parser


Version published
Weekly downloads
5.8M
increased by1.78%
Maintainers
1
Weekly downloads
 
Created

What is redis-parser?

The redis-parser npm package is designed for parsing responses from a Redis server. It supports both JavaScript and TypeScript and is capable of handling different types of Redis responses, including errors, simple strings, integers, bulk strings, arrays, and more. It's particularly useful for developers working with Redis in Node.js environments, providing a straightforward way to interpret the data returned by Redis commands.

What are redis-parser's main functionalities?

Error Handling

This feature allows handling of Redis errors. When a Redis server responds with an error, the parser can catch and process this error appropriately.

{"const { Parser } = require('redis-parser');
const parser = new Parser({
  returnError: function(err) { console.error('Error:', err); },
  returnReply: function(reply) { console.log('Reply:', reply); }
});
parser.execute(Buffer.from('-Error message\r\n'));
}

Parsing Simple Strings

This demonstrates how to parse simple string responses from Redis. It's useful for commands that return a simple status response.

{"const { Parser } = require('redis-parser');
const parser = new Parser({
  returnError: function(err) { console.error('Error:', err); },
  returnReply: function(reply) { console.log('Reply:', reply); }
});
parser.execute(Buffer.from('+OK\r\n'));
}

Parsing Arrays

This feature is for parsing array responses from Redis, which is common for commands that return multiple values.

{"const { Parser } = require('redis-parser');
const parser = new Parser({
  returnError: function(err) { console.error('Error:', err); },
  returnReply: function(reply) { console.log('Reply:', reply); }
});
parser.execute(Buffer.from('*2\r\n$3\r\nfoo\r\n$3\r\nbar\r\n'));
}

Other packages similar to redis-parser

Keywords

FAQs

Package last updated on 25 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc